﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LabMS.Web.Equipment.Valuables
{
    public partial class valuablesdamagereport : Base.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("GZSBBS");//必须写在ispostback外
            strPageUserType.Add("mana");
            if (!IsPostBack)
            {
                tbReportTime.Attributes.Add("onclick", "c.showMoreDay = false;c.show(this);");

                tbReportTime.Attributes.Add("readOnly", "-1");
                tbLowname.Attributes.Add("readOnly", "-1");
                tbLowNum.Attributes.Add("readOnly", "-1");
                tbApplyer.Attributes.Add("readOnly", "-1"); 
            }
        }

        protected void Submit(string status)
        {
            Model.GoodsMaintain goods = new LabMS.Model.GoodsMaintain();
            BLL.GoodsMaintain bgoods = new LabMS.BLL.GoodsMaintain();

            goods.LabName = tbLabNum.Text.Trim();
            goods.AssetManagers = tbManager.Text.Trim();
            goods.Tel = tbTelNum.Text.Trim();
            goods.Numbers = tbLowNum.Text.Trim();
            goods.Name = tbLowname.Text.Trim();
            goods.StorageSites = tbStoreAdd.Text.Trim();
            goods.Applicant = tbApplyer.Text.Trim();
            goods.Guarantee = isInTime.SelectedValue;
            DateTime tempTime = new DateTime();
            if (DateTime.TryParse(tbReportTime.Text.Trim(), out tempTime))
            {
                goods.ReportedTime = tempTime;
            }
            goods.Describe = tbDescription.Text.Trim();
            goods.Status = status;

            try
            {
                bgoods.Add(goods);
                LabMS.Common.JShelper.JSAlertAndRedirect(Page, "AddSuccess", "操作成功!", "valuablesdamagereport.aspx");
            }
            catch (Exception ex)
            {
                Err.Text = ex.Message.ToString();
            }
        }

        protected void lbReportDamage_Click(object sender, EventArgs e)
        {
            Submit("故障");
        }

        protected void lbReportDead_Click(object sender, EventArgs e)
        {
            Submit("报废");
        }

        protected void lbReportLost_Click(object sender, EventArgs e)
        {
            Submit("丢失");
        }
    }
}
